<?php

namespace app\model;

use app\BaseModel;
use think\model\relation\BelongsTo;
use app\model\not_del\UserModel as NotDelUserModel;

/**
 * 危机用户（危机上报）
 */
class CrisisUserModel extends BaseModel
{
    protected $name = 'crisis_user';


    /**
     * 关联用户
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'uid')->bind([
            'user_name' => 'name',
            'user_sex' => 'sex',
            'province_name',
            'city_name',
            'area_name',
            'user_number',
            'role_id',
            'role_mode',
            'role_name',
            'unit_name',
            'user_department_name' => 'department_name'
        ]);
    }

    /**
     * 关联操作人
     * @return BelongsTo
     */
    public function operator(): BelongsTo
    {
        return $this->belongsTo(NotDelUserModel::class, 'operator_uid')->bind([
            'operator_name' => 'name',
        ]);
    }
}